﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/common/header.jsp"%>
<c:set var="path" value="../..${ctx}/ship"/>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Pagination 分页表格</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<link href="${ctx}/demo/demo.css" rel="stylesheet" type="text/css" />
	
	<script src="${ctx}/scripts/boot.js" type="text/javascript"></script>
<style type="text/css">
    html, body{
        margin:0;padding:0;border:0;width:100%;height:100%;overflow:hidden;
    }    
    </style>
</head>
<body >

<!-- 
    <div style="padding-bottom:5px;">
        <span>员工姓名：</span><input type="text" id="key"  />
        <input type="button" value="查找" onclick="search()"/>
    </div>
 -->
 
     <div style="width:100%;">
        <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
            <table style="width:100%;">
                <tr>
                    <td style="width:100%;">
                        <a class="mini-button" iconCls="icon-add" onclick="add()">增加</a>
                        <a class="mini-button" iconCls="icon-add" onclick="edit()">编辑</a>
                        <a class="mini-button" iconCls="icon-remove" onclick="remove()">删除</a>       
                    </td>
                    <td style="white-space:nowrap;">
                        <input id="key" class="mini-textbox" emptyText="请输入姓名" style="width:150px;" onenter="onKeyEnter"/>   
                        <a class="mini-button" onclick="search()">查询</a>
                    </td>
                </tr>
            </table>           
        </div>
    </div>   

    
<!--撑满页面-->
<div class="mini-fit" >
<div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" 
    url="${path}/list.html"  idField="id" allowResize="true" multiSelect="true"
    sizeList="[20,30,50,100]" pageSize="20">

    <div property="columns">
        <div type="checkcolumn" ></div>
        <div type="indexcolumn" ></div>
        <div field="SHIP_NO" width="120" headerAlign="center" allowSort="true">船舶编号</div>    
        <div field="USER_NAME" width="120" headerAlign="center" allowSort="true">用户名</div>   
        <div field="REAL_NAME" width="120" headerAlign="center" allowSort="true">姓名</div>                         
        <div field="sex" width="100" renderer="onGenderRenderer" align="center" headerAlign="center">性别</div>
        <div field="salary" numberFormat="¥#,0.00" align="right" width="100" allowSort="true">薪资</div>                                
        <div field="age" width="100" allowSort="true" decimalPlaces="2" dataType="float">年龄</div>
        <div field="CREATE_TIME" width="100" headerAlign="center" dateFormat="yy-MM-dd" allowSort="true">创建日期</div>                
    </div>
</div>   
</div>
    <script type="text/javascript">
        mini.parse();

        var grid = mini.get("datagrid1");
        grid.load();

        function search() {
        	var key = mini.get("key").getValue();
            //var key = document.getElementById("key").value;
            grid.load({ name: key });
        }
/*         $("#key").bind("keydown", function (e) {
            if (e.keyCode == 13) {
                search();
            }
        }); */
        function onKeyEnter(e) {
            search();
        }

       function add() {
            
    	   top["win"].addTab("../..${ctx}/common/view.html?jsp=test/ship/ship_in_decl_edit");
    	   
/*     	   mini.open({
                url: bootPATH + "../..${ctx}/common/view.html?jsp=test/ship/ship_in_decl_edit",
                title: "新增进口岸申请", showMaxButton:true,width: '100%', height: '100%',
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var data = { action: "new"};
                    iframe.contentWindow.SetData(data);
                },
                ondestroy: function (action) {
                    grid.reload();
                }
            }); */
        }
       
        function edit() {
            var row = grid.getSelected();
            if (row) {
                mini.open({
                    url: bootPATH + "../demo/CommonLibs/EmployeeWindow.html",
                    title: "编辑员工", width: 600, height: 360,
                    onload: function () {
                        var iframe = this.getIFrameEl();
                        var data = { action: "edit", id: row.id };
                        iframe.contentWindow.SetData(data);
                        
                    },
                    ondestroy: function (action) {
                        grid.reload();
                        
                    }
                });
                
            } else {
                alert("请选中一条记录");
            }
        }

        function remove() {
            var rows = grid.getSelecteds();
            if (rows.length > 0) {
                if (confirm("确定删除选中记录？")) {
                    var ids = [];
                    for (var i = 0, l = rows.length; i < l; i++) {
                        var r = rows[i];
                        ids.push(r.id);
                    }
                    var id = ids.join(',');
                    grid.loading("操作中，请稍后......");
                    $.ajax({
                        url: "../data/AjaxService.aspx?method=RemoveEmployees&id=" +id,
                        success: function (text) {
                            grid.reload();
                        },
                        error: function () {
                        }
                    });
                }
            } else {
                alert("请选中一条记录");
            }
        }
        
        
        ///////////////////////////////////////////////////////
        var Genders = [{ id: 1, text: '男' }, { id: 0, text: '女'}];
        function onGenderRenderer(e) {
            for (var i = 0, l = Genders.length; i < l; i++) {
                var g = Genders[i];
                if (g.id == e.value) return g.text;
            }
            return "";
        }
    </script>

</body>
</html>